package com.ananjt.system.user.controller;


import com.ananjt.system.entity.SpUser;
import com.ananjt.system.user.service.SpUserService;
import com.ananjt.system.vo.SecurityUserDetails;
import com.ananjt.system.vo.UserRoleVo;
import com.ananjt.utils.context.CurrentUser;
import com.google.gson.Gson;
import com.sp.system.user.core.utils.ContentResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chenanhai
 * @since 2020-03-16
 */
@RestController
@RequestMapping("/user")
public class SpUserController {


    private SpUserService userService;

    /**
     * 获取用户信息
     *
     * @param loginName
     * @return
     */
    @PostMapping("/getSystemUserByLoginName")
    public Object getSystemUserByLoginName(String loginName) {
        UserRoleVo userDetails = userService.getSystemUserByLoginName(loginName);
        return userDetails;
    }

    @PostMapping("/getUserInfo")
    public Object getUserInfo() {
        SpUser spUser = userService.getById(CurrentUser.getUserId());
        spUser.setPassword("");
        return ContentResult.successResult(spUser,"查询用户信息");
    }

    @Autowired
    public void setUserService(SpUserService userService) {
        this.userService = userService;
    }
}

